from django.db import models


class Role(models.Model):
    """角色表"""
    role_name = models.CharField(verbose_name="角色名", max_length=16)
    label = models.ManyToManyField('Label', blank=True, verbose_name="菜单")

    def __str__(self):
        return self.role_name


class Label(models.Model):
    """菜单表"""
    label_name = models.CharField(verbose_name="菜单名", max_length=16)
    url = models.CharField(verbose_name="URL", max_length=64)

    def __str__(self):
        return self.label_name


class User(models.Model):
    """用户表"""
    login = models.CharField(verbose_name="登录账号", max_length=64, default=0)
    name = models.CharField(verbose_name="姓名", max_length=16)
    password = models.CharField(verbose_name="密码", max_length=64)
    age = models.IntegerField(verbose_name="年龄")
    sex = models.CharField(verbose_name="性别", max_length=16)
    email = models.CharField(verbose_name="邮箱", max_length=64)
    role = models.ManyToManyField('Role', blank=True, verbose_name="角色")

    def __str__(self):
        return self.name


class Admin(models.Model):
    """管理员"""
    admin_login = models.CharField(verbose_name="登录账号", max_length=64, default=0)
    admin_name = models.CharField(verbose_name="姓名", max_length=16)
    pwd = models.CharField(verbose_name="密码", max_length=64)
    age = models.IntegerField(verbose_name="年龄")
    sex = models.CharField(verbose_name="性别", max_length=16)
    email = models.CharField(verbose_name="邮箱", max_length=64)


